package com.xgpro.mapper.archives;

import com.xgpro.domain.archives.dto.Projectt;
import com.xgpro.domain.archives.entity.Project;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface ProjectMapper extends Mapper<Project> {

    @Select("<script>" +
            " select id,project_name as projectName,project_level as projectLevel ,project_post as projectPost , " +
            " project_introduce as projectIntroduce ,project_achievement as projectAchievement ," +
            " project_number as projectNumber,project_starttime as projectStarttime ,project_endtime as projectEndtime " +
            " from t_project  " +
            "<where>" +
            " <if test=\"userId != null \"> " +
            "    user_id=#{userId}" +
            " </if>" +
            " <if test=\"type != null and type!=''\"> " +
            "  and project_level=#{type}  " +
            " </if>" +
            " <if test=\"name != null and name!='' \"> " +
            "  and project_name like CONCAT('%',#{name},'%')" +
            " </if>" +
            "</where>" +
            "</script>")
    List<Projectt> getProject(@Param("userId") Integer userId, @Param("type") Integer type, @Param("name") String name);

    @Delete("<script>" +
            " delete from t_project where  id in " +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'> " +
            "  #{id}" +
            " </foreach>" +
            " </script>")
    Integer batchDeletes(List<Integer> ids);


    @Delete("<script>" +
            " delete from t_project where  user_id in " +
            " <foreach collection='list' index='index' item='id'  open='(' separator=',' close=')'> " +
            "  #{id}" +
            " </foreach>" +
            " </script>")
    Integer beletes(List<Integer> ids);
}
